import java.time.Duration;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args) {
        final int queueSize = 1;
        try (ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 100, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<>(queueSize))) {
            for (int i = 1; i <= 10; i++) {
                threadPoolExecutor.execute(() -> {
                    System.out.println(Thread.currentThread().getName() + ", queue is full ? " + (threadPoolExecutor.getQueue().size() == queueSize));
                    try {
                        Thread.sleep(Duration.ofMillis(300));
                    } catch (InterruptedException e) {
                        // ignore
                    }
                });
            }
        }
    }
}
